/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Modelo;

import BBDD.BaseConection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author David
 */
public class Admin extends Cliente{
   
    @Override
    public Admin obtenerCliente(final String user){
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        Admin c = new Admin();
        try {
            conn = DriverManager.getConnection(
                    BaseConection.getCadenaLocal(),
                    BaseConection.getUser(),
                    BaseConection.getPassword());
            stmt = conn.createStatement();
            rs = stmt.executeQuery("SELECT NOMBRE, APELLIDO, NUM_CLIENTE, EMAIL FROM USERS_ADMIN WHERE USUARIO="
                    + user);
            if (rs.next()) {
                 c.setNombre(rs.getString("NOMBRE"));
                 c.setApellido(rs.getString("APELLIDO"));
                 c.setNumCliente(Integer.parseInt(rs.getString("NUMCLIENTE")));
                 c.setEmail(rs.getString("EMAIL"));
                 c.setUsuario(user);
            }
            conn.close();
        } catch (SQLException exceptionSql) {
            System.out.print("Error:" + exceptionSql.getMessage());
        }
  return c;
    }
}
